package demo1;

import java.util.Scanner;

public class Demo2 {

    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int[] nums=new int[8];
        System.out.println("请输入8个正整数");
        for(int i=0;i< nums.length;i++){
            nums[i]=sc.nextInt();
        }
        int oddCount=0;
        int evenCount=0;
        for (int i=0;i< nums.length;i++){
            if(nums[i]%2==0){
                evenCount++;
            }else{
                oddCount++;
            }
        }
        int[] oddNums=new int[oddCount];
        int[] evenNums=new int[evenCount];
        oddCount=0;
        evenCount=0;
        for (int i=0;i< nums.length;i++){
            if(nums[i]%2==0){
                evenNums[evenCount]=nums[i];
                evenCount++;
            }else{
                oddNums[oddCount]=nums[i];
                oddCount++;
            }
        }

        printNums(oddNums,evenNums);


    }

    public static void printNums(int[] odds,int[] evens){
        int maxlenghth=odds.length;
        if(odds.length<evens.length){
            maxlenghth=evens.length;
        }
        for (int i=0;i<maxlenghth;i++){
            if(i< odds.length){
                System.out.println(odds[i]);
            }
            if(i< evens.length){
                System.out.println(evens[i]);
            }
        }
    }
}
